
names = [
    ["曹操", "56", "男", "106", "IBM", 500, "50"],
    ["大乔", "19", "女", "230", "微软", 501, "60"],
    ["小乔", "19", "女", "210", "Oracle", 600, "60"],
    ["许褚", "45", "男", "230", "Tencent", 700, "10"]
]
# 统计每个人的薪资

num1 = 0
for i in range(len(names)):
    num1 = num1 + names[i][5]
print("总薪资", num1)
average = num1 / len(names)
print("平均薪资", average)

# 统计每个人的平均年龄

num2 = 0
for i in range(len(names)):
    num2 = num2 + int(names[i][1])
print("总年龄和", num2)
age = num2 / len(names)
print("平均年龄", age)

# 公司里面插入一个员工
names.insert(4, ["刘备", "45", "男", 220, "alibaba", 500, "30"])
print(names)
# 统计公司男女人数
names_dic = {}
for ii in range(len(names)):
    for i in names[ii][2]:
        if i not in names_dic:
            names_dic[i] = 1
        else:
            names_dic[i] += 1
print(names_dic)
# 统计每个部门的人数
a = []
names1_dic = {}
for i in range(len(names)):
    a.append(names[i][4])
for ii in a:
    names1_dic[ii] = names1_dic.get(ii, 0) + 1
print(names1_dic)

# 现在魔法学院有赫敏、哈利、罗恩、马尔福四个人的几次魔法作业的成绩。但是呢
# ，因为有些魔法作业有一定难度，教授不强制同学们必须上交，
# 所以大家上交作业的次数并不一致。
name1 = ["罗恩", 23, 35, 44]
name2 = ["哈利", 60, 77, 68, 88, 90]
name3 = ["赫敏", 97, 99, 89, 91, 95, 90]
name4 = ["马尔福", 100, 85, 90]
name1_01 = 0
name2_02 = 0
name3_03 = 0
name4_04 = 0
for i in range(1, len(name1)):
    name1_01 = name1_01 + name1[i]
for i in range(1, len(name1)):
    name2_02 = name2_02 + name2[i]
for i in range(1, len(name1)):
    name3_03 = name3_03 + name3[i]
for i in range(1, len(name1)):
    name4_04 = name4_04 + name4[i]
print("罗恩的总成绩", name1_01)
print("哈利的总成绩", name2_02)
print("赫敏的总成绩", name3_03)
print("马尔福的总成绩", name4_04)

# 当输入是54321
num = int(input("请输入一个数:"))
while num != 0:
    print(num % 10)
    num = num // 10
    break
print(num)
# 请对下列列表进行冒泡排序
a = [5, 2, 4, 7, 1, 3, 5, 4, 0, 6, 1, 3]
print(a)
print(len(a))
for i in range(len(a)):
    for x in range(len(a) - i - 1):
        if a[x] > a[x + 1]:
            a[x], a[x + 1] = a[x + 1], a[x]
print(a)
